<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <?php
    if (isset($_POST['amount']) &&
        isset($_POST['currency']) &&
        isset($_POST['compound-interest']) &&
        isset($_POST['period'])) {
        $amount = $_POST['amount'];
        $currency = $_POST['currency'];
        $interest = $_POST['compound-interest'];
        $period = $_POST['period'];

        $interestPerMonth = $interest / $period;

        $result = $amount;

        for ($i = 0; $i < $period; $i++) {
            $result *= (100 + $interestPerMonth) / 100;
        }
    }
    ?>
</head>
<body>
<form action="interest-calculation.php" method="post">
    <label for="amount">Enter amount:</label>
    <input type="text" id="amount" name="amount">
    <label for="bgn">BGN</label>
    <input type="radio" id="bgn" name="currency" value="bgn" />
    <label for="usd">USD</label>
    <input type="radio" id="usd" name="currency" value="usd" />
    <label for="eur">EUR</label>
    <input type="radio" id="eur" name="currency" value="eur" />
    <label for="compound-interest">Compound interest amount:</label>
    <input type="text" id="compound-interest" name="compound-interest">
    <label for="period">Period:</label>
    <select id="period" name="period">
        <option value="6">6 months</option>
        <option value="12">1 year</option>
        <option value="24">2 years</option>
        <option value="60">5 years</option>
    </select>
    <input type="submit" name="calculate" value="Calculate">
</form>
<?php
if (isset($result))
    if ($currency === "usd") {
        $finalResult = "$" . round($result, 2);
    }
    else if ($currency === "eur") {
        $finalResult = "€" . round($result, 2);
    }
    else if ($currency === "bgn") {
        $finalResult = round($result, 2) . " levs";
    }

    echo $finalResult;
?>
</body>
</html>